import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  // {
  //   path: '/about',
  //   name: 'About',
  //   component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue')
  // },
  {
    path: '/cities',
    name: 'Cities',
    component: () => import(/* webpackChunkName: "cities" */ '@/views/Cities.vue'),
    children: [
      {
        path: 'show-city',
        name: 'Show-city',
        component: () => import(/* webpackChunkName: "show-city" */ '@/views/cities/ShowCity.vue')
      },
      {
        // 当 /user/:id/profile 匹配成功，
        // UserProfile 会被渲染在 User 的 <router-view> 中
        path: 'search-city',
        name: 'Search-city',
        component: () => import(/* webpackChunkName: "search-city" */ '@/views/cities/SearchCity.vue')
      },
      { path: '/cities', redirect: { name: 'Show-city' } }
    ]
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import(/* webpackChunkName: "search-page" */'@/views/Search.vue')
  },
  {
    path: '/classify',
    name: 'Classify',
    component: () => import(/* webpackChunkName: "classify" */ '@/views/Classify.vue')
  },
  // {
  //   path: '/classify/copy',
  //   name: 'Classify-details-copy',
  //   component: () => import('@/views/classify/Copy.vue')
  // },
  // {
  //   path: '/classify/spec',
  //   name: 'Classify-details-spec',
  //   component: () => import('@/views/classify/Spec.vue')
  // },
  {
    path: '/classify/details/:tradeItemId?',
    name: 'Classify-details-tradeItemId',
    component: () => import('@/views/classify/details/_tradeItemId.vue')
  },
  {
    path: '/paymentpage',
    name: 'Paymentpage',
    component: () => import('@/views/PaymentPage.vue')
  },
  {
    path: '/shopcart',
    name: 'Shopcart',
    component: () => import('@/views/Shoppingcart.vue')
  },
  {
    path: '/shopcart/address',
    name: 'Address',
    component: () => import(/* webpackChunkName: "address" */ '@/views/shop/address.vue'),
    children: [
      {
        path: 'list',
        name: 'Address-list',
        component: () => import(/* webpackChunkName: "address-list" */ '@/views/shop/address/Addresslist.vue')
      },
      {
        path: 'edit/:editType?',
        name: 'Address-edit',
        component: () => import(/* webpackChunkName: "address-edit" */ '@/views/shop/address/Addressedit.vue')
      },
      { path: '/shopcart/address', redirect: { name: 'Address-list' } }
    ]
  },
  {
    path: '/user/menu',
    name: 'Menu',
    component: () => import('@/views/user/menu.vue')
  },
  {
    path: '/user',
    name: 'User',
    component: () => import(/* webpackChunkName: "user" */ '@/views/User.vue'),
    children: [
      {
        path: ':nowsoon',
        name: 'Now-soon',
        component: () => import(/* webpackChunkName: "nowPlaying" */ '@/views/film/NowSoon.vue')
      },
      { path: '/user', redirect: { name: 'Now-soon', params: { nowsoon: 'nowPlaying' } } }
    ]
  },
  {
    path: '/user/fm_details/:filmId',
    name: 'Film-details',
    component: () => import(/* webpackChunkName: "film-details" */ '@/views/film/FilmDetails.vue')
  },
  {
    path: '/user/:type?',
    name: 'User-type',
    component: () => import(/* webpackChunkName: "user-type" */ '@/views/user/_type.vue')
  },
  { path: '', redirect: { name: 'Home' } },
  { path: '/', redirect: { name: 'Home' } },
  { path: '*', redirect: { name: 'Home' } }
]

const router = new VueRouter({
  mode: 'hash', // history
  base: process.env.BASE_URL,
  routes
})

export default router
